<template>
    <div  id="header2" class="header-box">
        <div class="header-inner pc flex-row">
            <div  class="left">
                <a  class="student">{{this.GLOBAL.title}}</a>
            </div>
            <span  class="left-arrow" style="display: none;">
		</span>
            <div class="nav-list">
                <div v-for="(item,index) in options">
                    <a :class="{active:currentIndex===index}" class="nav" @click="toRouter(item.label,index)">{{item.label}}</a>
                </div>
            </div>
            <div  class="right-navs flex-row">
                <el-button v-if="realName"  @click="LogOut" style="width: 100px;height: 40px;background-color: #00bf80;color: white;margin-right: 20px" >退出登录</el-button>
<!--                <el-image style="width: 50px;height: 50px;border-radius: 50%" v-if="realName" :src="user.imageUrl"></el-image>-->
                <el-button @click="toLogin" v-if="!realName" style="width: 100px;height: 40px;background-color: #00bf80;color: white;margin-right: 20px">登录</el-button>
                <a>
                    <span class="phone-left">
					<a class="left-logo">
                    <img v-if="realName" style="height: 50px;width: 50px;border-radius: 50%" :src="user.imageUrl" class="logo">
                </a>
				</span>
                </a>
            </div>
        </div>

    </div>
</template>

<script>


    import { getUserInfo } from '../../api/user';

    export default {
        name: 'NavHeader',
        data(){
            return{
                addOrUpdateVisible:true,
                form:{},
                user:{},
                url:require('../../assets/images/学习.png'),
                options:[
                    {
                        id:2,
                        label:'调剂推荐',
                        link: 'toOrganization'
                    },
                    // {
                    //     id:2,
                    //     label:'专业信息',
                    //     link: 'toOrganization'
                    // },
                    {
                        id:3,
                        label:'新闻公告'
                    },
                    // {
                    //     id:3,
                    //     label:'志愿填报'
                    // },
                    // {
                    //     id:3,
                    //     label:'答疑'
                    // },
                    {
                        id:5,
                        label:'个人中心'
                    },
                ],
                currentIndex:0,
                baseUrl:null

            }
        },
        computed: {
            realName(){
                return sessionStorage.getItem("realName");
            }
        },
        created() {
            if (sessionStorage.getItem('realName') !==null){
                this.getData();
            }
            if(sessionStorage.getItem('index')){
                this.currentIndex = Number(sessionStorage.getItem('index'))
            }
        },

        mounted() {
            // const that = this;
            // utilMethod.$on("success",function (data) {
            //     that.getData()
            // })
        },

        methods:{

            getData(){
                getUserInfo({id:sessionStorage.getItem('userId')}).then(res =>{
                    this.user = res.data.list[0];
                    this.baseUrl = res.baseUrl
                })
            },

            openDialog(){
                this.form = {};
                this.addOrUpdateVisible = true;
            },

            LogOut(){

              this.$router.push('/login')
                sessionStorage.clear();
            },

            toRouter(label,index){
                sessionStorage.setItem('userStatus','1');
                sessionStorage.setItem('index',index);
                this.currentIndex=index;
                if (label === '调剂推荐'){
                    this.$router.push('/index')
                }
                if (label === '专业信息'){
                    this.$router.push('/index-subject')
                }
                if (label === '教学通知'){
                    this.$router.push('/index-notice')
                }
                if (label === '考试信息'){
                    this.$router.push('/index-test')
                }
                if (label === '新闻公告'){
                    this.$router.push('/index-news')
                }
                if (label === '志愿填报'){
                    this.$router.push('/forum')
                }
                if (label === '答疑'){
                    this.$router.push('/chat')
                }
                if (label === '文件信息'){
                    this.$router.push('/index-document')
                }
                if (label === '个人中心'){
                    this.$router.push('/contact/person');
                }
            },

            toOrganization(){
                sessionStorage.setItem('userStatus','1');
                this.$router.push('/info')
            },


            toLogin(){
                sessionStorage.setItem('userStatus','1');
                this.$router.push('/login')
            },

        }
    };
</script>

<style scoped>







    .header-box{
        -webkit-backdrop-filter: blur(3px);
        backdrop-filter: blur(3px);
        background: hsla(0,0%,100%,.24);
        height: 64px;
        /*position: fixed;*/
        top: 0;
        width: 100%;
        z-index: 100;
    }
    *, :after, :before {
        --tw-ring-offset-width: 0px;
        --tw-ring-offset-color: #fff;
        --tw-ring-color: rgba(59,151,255,.5);
        --tw-ring-offset-shadow: 0 0 #0000;
        --tw-ring-shadow: 0 0 #0000;
    }
    *, :after, :before {
        --tw-shadow: 0 0 #0000;
    }
    .header-box .header-inner {
        -webkit-box-pack: justify;
        -webkit-box-align: center;
        -webkit-align-items: center;
        align-items: center;
        height: 100%;
        -webkit-justify-content: space-between;
        justify-content: space-between;
        margin: 0 32px;
    }
    .flex-row, .flex-row-center {
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        -webkit-box-align: center;
        -webkit-align-items: center;
        align-items: center;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-flow: row nowrap;
        flex-flow: row nowrap;
    }
    .header-box .header-inner .left {
        -webkit-box-align: center;
        -webkit-box-pack: center;
        -webkit-align-items: center;
        align-items: center;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-justify-content: center;
        justify-content: center;
    }
    .header-box .header-inner .left .left-logo {
        -webkit-box-pack: start;
        height: 30px;
        -webkit-justify-content: flex-start;
        justify-content: flex-start;
        width: 158px;
    }
    a {
        color: #333;
    }
    a:link, a:visited {
        text-decoration: none;
    }
    .header-box .header-inner .left .left-logo .logo {
        height: 28px;
        width: 156px;
    }
    fieldset, img {
        border: 0;
    }
    .header-box .header-inner .student {
        --tw-text-opacity: 1;
        background: rgba(0,191,128,.1);
        border-radius: 4px;
        color: #00bf80;
        color: rgba(0,191,128,var(--tw-text-opacity));
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        margin-left: 8px;
        padding: 5px 12px;
        text-align: center;
        white-space: nowrap;
    }
    .ncicon.ncicon-bleed{
        vertical-align: -0.15em;
    }
    .ncicon {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        display: inline-block;
        font-style: normal;
        line-height: 0;
        text-align: center;
        text-transform: none;
        vertical-align: -0.125em;
    }
    .ncicon svg {
        display: inline-block;
    }
    .ncicon[data-v-6acb0236]>* {
        line-height: 1;
    }
    @media (min-width: 1490px) {
        .header-box .header-inner .nav-list{
            margin-left: 60px;
        }
        .header-box .header-inner .nav-list {
            margin-right: 32px;
        }
        .header-box .header-inner .nav-list .nav {
            margin-right: 32px;
            cursor: pointer;
        }
    }
    .header-box .header-inner .nav-list {
        -webkit-box-flex: 2;
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        -webkit-box-align: center;
        -webkit-box-pack: center;
        -webkit-align-items: center;
        align-items: center;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-flex: 2;
        flex: 2;
        -webkit-flex-flow: row nowrap;
        flex-flow: row nowrap;
        height: 100%;
        -webkit-justify-content: center;
        justify-content: center;
        margin-left: 60px;
    }
    .header-box .header-inner .nav-list .active{
        color: #00BF80;
        display: inline-block;
        font-weight: 600;
        position: relative;
    }
    .active{
        color: #00BF80;
        display: inline-block;
        font-weight: 600;
        position: relative;
    }
    .header-box .header-inner .nav-list .nav {
        font-size: 16px;
        line-height: 16px;
    }
    .header-box .header-inner .nav-list .active:after {
        background: #00BF80;
        border-radius: 1px;
        bottom: -12px;
        content: "";
        height: 2px;
        left: 50%;
        position: absolute;
        -webkit-transform: translateX(-50%);
        transform: translateX(-50%);
        width: 16px;
    }
    .header-box .header-inner .nav-list .nav{
        color: #666;
        font-size: 16px;
        line-height: 16px;
        margin-right: 32px;
        white-space: nowrap;
    }
    .header-box .header-inner .right-navs {
        -webkit-box-flex: 1;
        -webkit-box-pack: end;
        -webkit-flex: 1;
        flex: 1;
        height: 40px;
        -webkit-justify-content: flex-end;
        justify-content: flex-end;
    }
    .flex-row, .flex-row-center {
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        -webkit-box-align: center;
        -webkit-align-items: center;
        align-items: center;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-flow: row nowrap;
        flex-flow: row nowrap;
    }

    .header-box .header-inner .right-navs .login {
        --tw-text-opacity: 1;
        color: #333;
        color: rgba(51,51,51,var(--tw-text-opacity));
        font-family: PingFangSC-Regular,PingFang SC;
        font-size: 16px;
        font-weight: 400;
        height: 16px;
        line-height: 16px;
        margin-right: 24px;
        white-space: nowrap;
    }
    .header-box .header-inner .right-navs .free_trial{
        -webkit-box-align: center;
        -webkit-box-pack: center;
        --tw-bg-opacity: 1;
        --tw-text-opacity: 1;
        -webkit-align-items: center;
        align-items: center;
        background-color: #00bf80;
        background-color: rgba(0,191,128,var(--tw-bg-opacity));
        border-radius: 4px;
        color: #fff;
        color: rgba(255,255,255,var(--tw-text-opacity));
        cursor: pointer;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        font-size: 16px;
        height: 16px;
        -webkit-justify-content: center;
        justify-content: center;
        margin-right: 20px;
        padding: 11px 16px;
        white-space: nowrap;
        width: 64px;
    }
    .header-box .header-inner .right-navs .phone {
        -webkit-box-align: center;
        -webkit-box-pack: center;
        -webkit-align-items: center;
        align-items: center;
        background-color: initial;
        border: 1px solid #00BF80;
        border-radius: 20px;
        box-sizing: border-box;
        color: #00BF80;
        cursor: pointer;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        height: 36px;
        -webkit-justify-content: center;
        justify-content: center;
        overflow: hidden;
        padding: 3px;
        position: relative;
        width: 150px
    }
    .header-box .header-inner .right-navs .phone .phone-bg{
        background: -webkit-linear-gradient(left,#00BF80,#00BF80);
        background: linear-gradient(90deg,#00BF80,#00BF80);
        border-radius: 16px;
        height: 30px;
        left: 5px;
        position: absolute;
        top: 50%;
        -webkit-transform: translateY(-50%);
        transform: translateY(-50%);
        -webkit-transition: all .4s ease;
        transition: all .4s ease;
        width: 30px;
        z-index: 1;
    }
    .header-box .header-inner .right-navs .phone .phone-left {
        background-color: #00BF80;
        border-radius: 50%;
        height: 30px;
        left: 5px;
        overflow: hidden;
        position: absolute;
        top: 50%;
        -webkit-transform: translateY(-50%);
        transform: translateY(-50%);
        width: 30px;
        z-index: 2;
    }
    .header-box .header-inner .right-navs .phone .phone-left .phone-image {
        height: 100%;
        width: 100%;
    }
    .header-box .header-inner .right-navs .phone .is-hover {
        display: none;
        opacity: 0;
    }
    .header-box .header-inner .right-navs .phone .phone-number {
        text-align: center;
        margin-left: 25px;
        width: 140px;
        z-index: 1;
    }

</style>
